package ly.gupao.edu.java8.example3;

import ly.gupao.edu.java8.Apple;

import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Predicate;

/**
 * @author: liyang
 * @date：2018/9/4 0004
 * describe：
 */
public class Example_3_Consumer {

    public static void main(String[] args) {
        List<Apple> list = Arrays.asList(new Apple("red", 1.2), new Apple("green", 2.2));
        consumer(list, (Apple a) -> System.out.println(a.getColor()));
    }

    public static <T> void consumer(List<T> list, Consumer<T> c){
        list.stream().forEach( e -> c.accept(e));
    }

}
